<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Framework - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.queue.framework.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.queue.framework.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.queue.example.html">Example usage</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.queue.html">Zend_Queue</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.queue.adapters.html">Adapters</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.queue.framework" class="section"><div class="info"><h1 class="title">Framework</h1></div>
    

    <p class="para">
        The <span class="classname">Zend_Queue</span> is a proxy that hides the details
        of the queue services. The queue services are represented by
        <span class="classname">Zend_Queue_Adapter_&lt;service&gt;</span>. For example,
        <span class="classname">Zend_Queue_Adapter_Db</span> is a queue that will use
        database tables to store and retrieve messages.
    </p>

    <p class="para">
        Below is an example for using database tables for a queuing system:
    </p>

    <pre class="programlisting brush: php">
$options = array(
    &#039;name&#039;          =&gt; &#039;queue1&#039;,
    &#039;driverOptions&#039; =&gt; array(
        &#039;host&#039;      =&gt; &#039;127.0.0.1&#039;,
        &#039;port&#039;      =&gt; &#039;3306&#039;,
        &#039;username&#039;  =&gt; &#039;queue&#039;,
        &#039;password&#039;  =&gt; &#039;queue&#039;,
        &#039;dbname&#039;    =&gt; &#039;queue&#039;,
        &#039;type&#039;      =&gt; &#039;pdo_mysql&#039;
    )
);

// Create a database queue.
// Zend_Queue will prepend Zend_Queue_Adapter_ to &#039;Db&#039; for the class name.
$queue = new Zend_Queue(&#039;Db&#039;, $options);
</pre>


    <p class="para">
        The <span class="classname">Zend_Queue</span> constructor will create a
        <span class="classname">Zend_Queue_Adapter_Db</span> and initialize the adapter
        with the configuration settings.
    </p>

    <p class="para">
        The accepted configuration settings for each adapter are provided
        in the <a href="zend.queue.adapters.html" class="link">adapter notes</a>.
    </p>

    <p class="para">
        <span class="classname">Zend_Queue</span> returns messages using the class
        <span class="classname">Zend_Queue_Message_Iterator</span>, which is an
        implementation of <acronym class="acronym">SPL</acronym> <span class="classname">Iterator</span> and
        <span class="classname">Countable</span>.
        <span class="classname">Zend_Queue_Message_Iterator</span> contains an array of
        <span class="classname">Zend_Queue_Message</span> objects.
    </p>

    <pre class="programlisting brush: php">
$messages = $queue-&gt;receive(5);
foreach ($messages as $i =&gt; $message) {
    echo &quot;$i) Message =&gt; &quot;, $message-&gt;body, &quot;\n&quot;;
}
</pre>


    <p class="para">
        Any exceptions thrown are of class
        <span class="classname">Zend_Queue_Exception</span>.
    </p>

    <div class="section" id="zend.queue.framework.basics"><div class="info"><h1 class="title">Introduction</h1></div>
        

        <p class="para">
            <span class="classname">Zend_Queue</span> is a proxy class that represents
            an adapter.
        </p>

        <p class="para">
            The  <span class="methodname">send()</span>,
             <span class="methodname">count($queue)</span>, and
             <span class="methodname">receive()</span> methods are employed by each
            adapter to interact with queues.
        </p>

        <p class="para">
            The  <span class="methodname">createQueue()</span>,
             <span class="methodname">deleteQueue()</span> methods are used to manage
            queues.
        </p>
    </div>

    <div class="section" id="zend.queue.framework.support"><div class="info"><h1 class="title">Commonality among adapters</h1></div>
        

        <p class="para">
            The queue services supported by <span class="classname">Zend_Queue</span> do
            not all support the same functions. For example,
            <span class="classname">Zend_Queue_Adapter_Array</span>,
            <span class="classname">Zend_Queue_Adapter_Db</span>, support all functions,
            while <span class="classname">Zend_Queue_Adapter_Activemq</span> does not
            support queue listing, queue deletion, or counting of messages.
        </p>

        <p class="para">
            You can determine what functions are supported by using
             <span class="methodname">Zend_Queue::isSupported()</span> or
             <span class="methodname">Zend_Queue::getCapabilities()</span>.
        </p>

        <ul class="itemizedlist">
            <li class="listitem">
                <p class="para">
                    <em class="emphasis"> <span class="methodname">createQueue()</span></em> - create a queue
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"> <span class="methodname">deleteQueue()</span></em> - delete a queue
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"> <span class="methodname">send()</span></em> - send a message
                </p>

                <p class="para">
                     <span class="methodname">send()</span> is not available in all adapters; the
                    <span class="classname">Zend_Queue_Adapter_Null</span> does not
                    support  <span class="methodname">send()</span>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"> <span class="methodname">receive()</span></em> - receive messages
                </p>

                <p class="para">
                     <span class="methodname">receive()</span> is not available in all adapters;
                    the <span class="classname">Zend_Queue_Adapter_Null</span> does not
                    support  <span class="methodname">receive()</span>.
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"> <span class="methodname">deleteMessage()</span></em> - delete a
                    message
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"> <span class="methodname">count()</span></em> - count the number of
                    messages in a queue
                </p>
            </li>

            <li class="listitem">
                <p class="para">
                    <em class="emphasis"> <span class="methodname">isExists()</span></em> - checks the existence
                    of a queue
                </p>
            </li>
        </ul>

        <p class="para">
             <span class="methodname">receive()</span> methods are employed by each
            adapter to interact with queues.
        </p>

        <p class="para">
            The  <span class="methodname">createQueue()</span> and
             <span class="methodname">deleteQueue()</span> methods are used to manage
            queues.
        </p>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.queue.example.html">Example usage</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.queue.html">Zend_Queue</a></span><br />
                        <span class="home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.queue.adapters.html">Adapters</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="manual.html">Guia de Refer&ecirc;ncia do Programador</a></li>
  <li class="header up"><a href="reference.html">Refer&ecirc;ncia do Zend Framework</a></li>
  <li class="header up"><a href="zend.queue.html">Zend_Queue</a></li>
  <li><a href="zend.queue.introduction.html">Introduction</a></li>
  <li><a href="zend.queue.example.html">Example usage</a></li>
  <li class="active"><a href="zend.queue.framework.html">Framework</a></li>
  <li><a href="zend.queue.adapters.html">Adapters</a></li>
  <li><a href="zend.queue.custom.html">Customizing Zend_Queue</a></li>
  <li><a href="zend.queue.stomp.html">Stomp</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>